<!-- 主页面头部标题及账户功能 -->
<template>
    <div class="header">
        <h1 class="title">千羽千寻会员系统</h1>
        <el-dropdown trigger="click">
            <span class="el-dropdown-link">
                {{ adminStore.adminname }}
                <el-icon class="el-icon--right">
                    <arrow-down />
                </el-icon>
            </span>
            <template #dropdown>
                <el-dropdown-menu>
                    <el-dropdown-item>Action 1</el-dropdown-item>
                    <el-dropdown-item>
                        Action 2
                    </el-dropdown-item>
                    <el-dropdown-item>Action 3</el-dropdown-item>
                    <el-dropdown-item>Action 4</el-dropdown-item>
                    <el-dropdown-item @click="logOut">退出登录</el-dropdown-item>
                </el-dropdown-menu>
            </template>
        </el-dropdown>
    </div>
</template>
<script setup>
import { useAdminStore } from '../../stores/admin-store';
import { useRouter } from 'vue-router'
const router = useRouter();
const adminStore = useAdminStore();
console.log(adminStore.adminname);

function logOut() {
    localStorage.removeItem('token');
    localStorage.removeItem('adminname');
    adminStore.setAdminname('');
    router.push('/');
}
</script>
<style scoped>
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 40px;
}

.el-dropdown-link {
    cursor: pointer;
}

.title {
    text-align: center;
    font-size: 40px;
    font-weight: bold;
    padding: 10px 0;
    color: rgb(49, 84, 117);
}
</style>